#pragma once
#include "winsock2.h"
#include "windows.h"
#include "ThreadPool.h"
#include "WorkThread.h"
#include "map"
#include "vector"

class CConMrg
{
public:
    CConMrg();
    ~CConMrg();

    unsigned __stdcall ThreadProc();
    
    static  void CloseConnect(WorkThread* pThread);
    void    GetMatchIDList(std::vector<DWORD>& vecMatchList);
    void    GetWaitMatchList(std::vector<DWORD>& vecMatchList);
protected:
     BOOL    Unpack(char* pBuf, size_t uSize, SOCKET sSocket);
     static LRESULT WINAPI EventWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

     void ConAccept();

     HWND SetupWindow();
     BOOL Init();
     void UnInit();
private:
    SOCKET  m_hListenSock;
    SOCKET  m_sTemp;
    std::vector<SOCKET>     m_vecAllSocket;
    std::map<DWORD, SOCKET> m_mapWaitingMat;
    HANDLE  m_hMatchThread;
    static DWORD            m_dwMatchID;
    static ThreadPool              m_oThreadPool;
    fd_set m_rfd;
    HANDLE  m_hListenThread;
    HWND    m_hWnd;
};



